package com.mg.plugin.agrometeorology.common;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class TemperatureData {

    public static double[] getVar(int month, int day, boolean b) {
        int level = 0;
        if (day < 10) {
            level = 1;
        } else if (day < 20) {
            level = 2;
        } else {
            level = 3;
        }
        JSONArray dataList = b ? ConfigReader.getInstance().getTempRiceSuitCode()
                : ConfigReader.getInstance().getTempSuitCode();
        for (Object tmp : dataList) {
            JSONObject data = (JSONObject) tmp;
            if (data.getString("key").equals(month + "_" + level)) {
                return new double[]{
                        data.getDouble("minValue"),
                        data.getDouble("maxValue"),
                        data.getDouble("value")
                };
            }
        }
        return null;
    }
}
